<template>
  <div class="box">
    <BaseIframe ref="baseIframeRef" :srcLong="srcLong" />
  </div>
</template>

<script>
/**
 * 审批时，需要展示第三方的详情，通过该组件统一进行处理
 */
import Vue from 'vue'

import BaseIframe from '@/components/BaseIframe'

export default {
  name: 'GeneralThirdDetail',
  components: {
    BaseIframe
  },
  props: {},
  data() {
    return {
      hostUrl: process.env.VUE_APP_ENTERPRISEPLANNING_BASEURL,
      // hostUrl: 'https://testpm.cscecxn.com/enterprise',
      token: Vue.getAcloudProvider().getAccessToken(),
      srcLong: null
    }
  },
  created() {
    const { businessType, businessId } = this.$route.query

    // 年计划 34001
    if (businessType === '34001' || businessType === '34004') {
      this.srcLong = `${this.hostUrl}/plan/yearView?planId=${businessId}&token=${this.token}`
    }
    // 月计划 34002
    else if (businessType === '34002' || businessType === '34005') {
      this.srcLong = `${this.hostUrl}/plan/monthView?planId=${businessId}&token=${this.token}`
    }
    // 督办 34003
    else if (businessType === '34003') {
      this.srcLong = `${this.hostUrl}/supervision/editSupervise?type=look&state=3&id=${businessId}&token=${this.token}`
    }
  },
  mounted() {
    /**
     * BaseIframe 组件内部 mounted 重新设置了高度导致本组件通过 props 传入的高度无效
     * 不敢修改 BaseIframe
     * 因此只能在本组件中再次覆盖 BaseIframe 组件内的高度设置
     * 截止 2023/3/28，此逻辑应用于 created 内的三个模块
     */
    this.$refs['baseIframeRef'].iframeHeight = window.screen.availHeight - 80 + 'px'
  }
}
</script>

<style scoped lang="less"></style>
